<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% content_for :page_title, t(:page_title, "Rubrics") %>
<% add_crumb t('#crumbs.rubrics', "Rubrics") %>
<% content_for :right_side do %>
  <a href="<%= context_url(@context, :context_rubrics_url) %>" class="btn button-sidebar-wide add_rubric_link">
    <i class="icon-add"></i>
    {{#t}}Add Rubric{{/t}}
  </a>
<% end %>

<% js_bundle :edit_rubric %>
<% css_bundle :learning_outcomes %>
<% content_for :stylesheets do %>
  <style>
    #rubrics .find_rubric_link {
      display: none;
    }
  </style>
<% end %>
<% js_bundle 'legacy/rubrics_index' %>
<h1>
  <% case @context.class.to_s %>
    <% when 'Course' %>
      <%= t 'course_rubrics', "Course Rubrics" %>
    <% when 'User' %>
      <%= t 'user_rubrics', "User Rubrics" %>
    <% when 'Account' %>
      <%= t 'account_rubrics', "Account Rubrics" %>
  <% end %>
</h1>
<a href="<%= context_url(@context, :context_rubrics_url) %>" id="add_rubric_url" style="display: none;">&nbsp;</a>
<div id="rubrics" class="raw_listing">
  <ul>
  <% @rubric_associations.each do |association| %>
    <% rubric = association.rubric %>
    <li>
      <a href="<%= context_url(@context, :context_rubric_url, association.rubric_id) %>" class="title"><%= rubric.title %></a>
      <span class="links">
        <% if can_do(rubric, @current_user, :update) %>
          <a href="<%= context_url(@context, :context_rubric_url, association.rubric_id) %>#edit" class="hide-till-hover" aria-label="{{#t}}Edit Rubric') %>" title="<%= t('edit_rubric', 'Edit Rubric{{/t}}"><i class="icon-edit standalone-icon"></i></a>
        <% end %>
        <% if can_do(association, @current_user, :delete) %>
          <a href="<%= context_url(@context, :context_rubric_url, rubric.id) %>" class="delete_rubric_link hide-till-hover" title="{{#t}}Delete Rubric') %>" aria-label="<%= t('delete_rubric', 'Delete Rubric{{/t}}"><i class="icon-end standalone-icon"></i></a>
        <% end %>
      </span>
      <span class="details">
        <%= t({:one => "1 criterion", :other => "%{count} criteria"}, :count => rubric.criteria.length) %><br/>
        <%= t('points_possible', {:one => "1 point possible", :other => "%{count} points possible"}, :count => round_if_whole(rubric.points_possible)) %>
      </span>
    </li>
  <% end %>
  </ul>
  <div style="display: none;" id="rubric_parameters">
    <input type="hidden" name="rubric_association[association_type]" value="<%= @context.class.to_s %>"/>
    <input type="hidden" name="rubric_association[association_id]" value="<%= @context.id %>"/>
    <input type="hidden" name="rubric_association[purpose]" value="bookmark"/>
  </div>
  <span class="current_user_id" style="display: none;"><%= @current_user.id %></span>
  <a href="<%= context_url(@context, :context_rubrics_url) %>" class="add_rubric_association_url" style="display: none;">&nbsp;</a>
</div>
{{> views/shared/find_outcome}}
{{> views/shared/rubric}}
{{> views/shared/rubric_forms}}
{{> views/shared/rubric_criterion_dialog}}
